import { http } from "@/utils/http";

// type ResultTable = {
//   total?: number;
//   data?: Array<any>;
// };
type GroupListItem = {
  id?: number;
  code?: string;
  name?: string;
  className?: string;
  classNameDesc?: string;
  opsOperateList?: [
    {
      id?: number;
      operateId?: number;
      operateName?: string;
      agentId?: number;
      agentName?: string;
    }
  ];
};
type GroupList = {
  data?: Array<GroupListItem>;
};
type SaveRes = {
  success?: Boolean;
  code?: string;
  msg?: string;
};
//新增运维组
export const saveOpsGroup = (data?: object) => {
  return http.request<SaveRes>("post", "/digitaltwins/api/v1/opsGroup/saveOpsGroup", {
    data
  });
};
//编辑运维组
export const updateOpsGroup = (data?: object) => {
  return http.request<SaveRes>("post", "/digitaltwins/api/v1/opsGroup/updateOpsGroup", {
    data
  });
};
//删除运维组
export const delOpsGroup = (data?: { id: number }) => {
  return http.request<GroupList>("post", `/digitaltwins/api/v1/opsGroup/delOpsGroup/${data.id}`, {});
};
//运维组列表
export const queryGroupList = (data?: object) => {
  return http.request<GroupList>("post", "/digitaltwins/api/v1/opsGroup/queryList", {
    data
  });
};
//运维人员列表
export const queryOperateList = (data?: { id: number }) => {
  return http.request<GroupList>("post", `/digitaltwins/api/v1/opsGroup/queryOperateList/${data.id}`, {});
};
// 新增人员列表
export const saveOpsGroupOperate = (data?: object) => {
  return http.request<GroupList>("post", "/digitaltwins/api/v1/opsGroup/saveOpsGroupOperate", {
    data
  });
};
//删除运维组
export const delOpsGroupOperate = (data?: { id: number }) => {
  return http.request<GroupList>("post", `/digitaltwins/api/v1/opsGroup/delOpsGroupOperate/${data.id}`, {});
};
//更新运维组
export const updateOpsGroupOperate = (data?: object) => {
  return http.request<GroupList>("post", "/digitaltwins/api/v1/opsGroup/updateOpsGroupOperate", {
    data
  });
};
